#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>
int is_leap_year(int y)
{
	if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
		return 1;
	else
		return 0;
}
int fun(int y, int m, int d)
{
	int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (is_leap_year(y) == 1)
		arr[2]++;
	if (m > 12 || m < 1)
		return 0;
	else if (d > arr[m] || d < 1)
		return 0;
	return 1;
}
int main()
{
	int a = 0, b = 0, c = 0, i = 0, year = 0, month = 0, day = 0;
	scanf("%d/%d/%d", &a, &b, &c);
	for (i = 19600101; i <= 20591231; i++)
	{
		year = i / 10000;
		month = i / 100 % 100;
		day = i % 100;
		if (fun(year, month, day) == 1)
		{
			if ((year % 100 == a && month == b && day == c) || (month == a && day == b && year % 100 == c)
				|| (day == a && month == b && year % 100 == c))
				printf("%d-%02d-%02d\n", year, month, day);
		}
	}

	return 0;
}